import React from 'react'
import { BrowserRouter, Routes, Route,Navigate } from 'react-router-dom'

const Home = React.lazy(() => import('../pages/Home'))
const FenLei = React.lazy(() => import('../pages/FenLei'))
const MiQuan = React.lazy(() => import('../pages/MiQuan'))
const Car = React.lazy(() => import('../pages/Car'))
const My = React.lazy(() => import('../pages/My'))

import Layout from '../pages/Layout'
import Tabbars from '../components/Tabbar'

const TuiJian = React.lazy(() => import('../pages/home/TuiJian'))
const ShouJi = React.lazy(() => import('../pages/home/ShouJi'))
const ZhiNeng = React.lazy(() => import('../pages/home/ZhiNeng'))
const DianShi = React.lazy(() => import('../pages/home/DianShi'))
const JiaDian = React.lazy(() => import('../pages/home/JiaDian'))
const BijiBen = React.lazy(() => import('../pages/home/BijiBen'))

const AppRouter = () => {
    return (
        <BrowserRouter>
            <Layout>
                {/* 底部导航栏 */}
                <Tabbars></Tabbars>

                <Routes>
                    {/* 一级路由 */}
                    <Route path='/home' element={<Home />}>
                        {/* 二级路由 */}
                        <Route index element={<TuiJian />} />
                        <Route path='/home/shouji' element={<ShouJi />} />
                        <Route path='/home/zhineng' element={<ZhiNeng />} />
                        <Route path='/home/dianshi' element={<DianShi />} />
                        <Route path='/home/jiadian' element={<JiaDian />} />
                        <Route path='/home/bijiben' element={<BijiBen />} />
                    </Route>
                    <Route path='/fenlei' element={<FenLei />} />
                    <Route path='/miquan' element={<MiQuan />} />
                    <Route path='/car' element={<Car />} />
                    <Route path='/my' element={<My />} />
                    {/* 首页默认 */}
                    <Route path='/' element={<Navigate to={'/home'} />} />

                </Routes>
            </Layout>
        </BrowserRouter>
    )
}

export default AppRouter
